package club.zhilin.guli.service.statistics.task;

import club.zhilin.guli.service.statistics.service.IDailyService;
import lombok.RequiredArgsConstructor;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author zhilin
 * @since 2022/3/6 16:11
 */
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScheduledTask {

    private final IDailyService iDailyService;

    /**
     * 定时任务
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void genStatisticsData() {
        iDailyService.createStatisticsByDate(new DateTime().minusDays(1).toString("yyyy-MM-dd"));
    }
}
